//
//  EAGLView.h
//  BioBreak
//
//  Created by terry franguiadakis on 2/17/09.
//  Copyright __MyCompanyName__ 2009. All rights reserved.
//


#import <UIKit/UIKit.h>
#import <OpenGLES/EAGL.h>
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>

#import "nnprotocol.h"

class Texture2D;

@interface AlertPrompt : UIAlertView 
{
    
}

@end

/*
This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
The view content is basically an EAGL surface you render your OpenGL scene into.
Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
*/
@interface EAGLView : UIView  <NNCommandResponder> {
    
@private
    /* The pixel dimensions of the backbuffer */
    GLint backingWidth;
    GLint backingHeight;
    
    EAGLContext *context;
    
    /* OpenGL names for the renderbuffer and framebuffers used to render to this view */
    GLuint viewRenderbuffer, viewFramebuffer;
    
    /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
    GLuint depthRenderbuffer;
    
    NSTimer *animationTimer;
    NSTimeInterval animationInterval;
    
    float tapPos_x; // ajusted tap poses. 
    float tapPos_y;
    
  //  NSString* tmpString;
   // Texture2D* tmpLabel;
    
    bool    m_pinching;
    float   m_pinchZoom;
    float   m_pinchDist;
    
    
    NSMutableDictionary* m_textures; 
}

@property NSTimeInterval animationInterval;

- (void)startAnimation;
- (void)stopAnimation;
- (void)drawView;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;

- (Texture2D*)CreateTexture:(NSString*)i_name; // creates a texture - ready to be initialized adds it to the list
- (Texture2D*)GetTexture:(NSString*)i_name;
- (void)DeleteTexture:(GLint)textureId; // find texture by id, then delete it. 

#if DEBUG
- (void)NNCommand:(const char*)dataBuffer;
#endif //DEBUG

+ (EAGLView *)sharedSingleton;

@end
